﻿namespace _32_C_中ref引用传递和ref返回值
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "C#中ref引用传递和ref返回值";

            //string str="";

            //show(ref str);

            //int a = 111;
            //int b = 222;
            //Console.WriteLine($"交换前：a{a} b{b}");
            //Swap(ref a,ref b);
            //Console.WriteLine($"交换后：a{a} b{b}");

            PersonCollection personCollection = new PersonCollection();

            Person person = personCollection.GetPerson("张三");

            person.Name = "王五";

           ref Person person1 =ref personCollection.GetPersonref("王五");

            person1 = new Person()
            {
                Id = 1,
                Name = "赵六"
            };

            personCollection.Show();

            Console.ReadKey();
        }

        static void Swap(ref int a, ref int b)
        {
            int temp = a;
            a = b;
            b = temp;
        }

        //static void show(ref string str)
        //{
        //    Console.WriteLine(str);
        //}
    }
}
